package com.zh.complaint.service.impl;


import com.zh.common.utils.ShiroUtils;
import com.zh.common.utils.StringUtil;
import com.zh.complaint.dao.AdviceDao;
import com.zh.complaint.service.AdviceService;
import com.zh.complaint.domain.AdviceDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;


@Service
public class AdviceServiceImpl implements AdviceService {
	@Autowired
	private AdviceDao adviceDao;
	
	@Override
	public AdviceDO get(String id){
		return adviceDao.get(id);
	}
	
	@Override
	public List<AdviceDO> list(Map<String, Object> map){
		return adviceDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return adviceDao.count(map);
	}
	
	@Override
	public int save(AdviceDO adviceDO){
		adviceDO.setId(StringUtil.generalKeyword());
		adviceDO.setStatus(1);//未处理
		//adviceDO.setMsgType(1);//监管网站1
		adviceDO.setCreateTime(new Date());
		adviceDO.setMsgTitle(adviceDO.getSenderName()+"的投诉");
		return adviceDao.save(adviceDO);
	}
	
	@Override
	public int update(AdviceDO adviceDO){
		AdviceDO adviceDO1 = adviceDao.get(adviceDO.getId());
		adviceDO1.setStatus(0);
		adviceDO1.setUpdateTime(new Date());
		adviceDO1.setUpdateUserId(ShiroUtils.getUserId());
		adviceDO1.setRemark(adviceDO.getRemark());
		return adviceDao.update(adviceDO1);
	}
	
	@Override
	public int remove(String id){
		return adviceDao.remove(id);
	}
	
	@Override
	public int batchRemove(String[] ids){
		return adviceDao.batchRemove(ids);
	}

    @Override
    public int selectcountCalling() {
        return adviceDao.selectcountCalling();
    }

}
